package com.wangbl.infomanager;


import android.app.Activity;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public abstract class BaseActivity extends Activity {
	protected TextView title_text;
	protected ImageView title_user;
	protected ImageView title_back;
	protected ImageView title_menu;
	protected Dialog pd;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		title_text = (TextView) findViewById(R.id.tv_title_text);
		title_user = (ImageView) findViewById(R.id.iv_title_user);
		title_back = (ImageView) findViewById(R.id.btn_title_back);
		title_menu = (ImageView) findViewById(R.id.iv_title_menu);
		pd = new Dialog(this, R.style.CustomProgressDialog);
		pd.setContentView(R.layout.progress_dialog);
		title_back.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				onBackPressed();
			}
		});
		pd.setOnCancelListener(new OnCancelListener() {
			
			@Override
			public void onCancel(DialogInterface dialog) {
				interrupt();
			}
		});
		
	}

	protected void setTitleText(String text) {
		title_text.setText(text);
	}

	/**
	 * Toast
	 * 
	 * @param content
	 */
	protected void toast(String content) {
		Toast toast = Toast.makeText(this.getApplicationContext(), content,
				Toast.LENGTH_SHORT);
		toast.show();
	}
	
	@Override
	public void onBackPressed() {
		super.onBackPressed();
		interrupt();
	}
	
	
	protected abstract void interrupt();

}
